//茶叶回显
window.onload= function(){
    let cookieStr= document.cookie;
    let cookirArr=cookieStr.split(";");
    let bool=false;
    let username;;
    for(let i=0;i<cookirArr.length;i++){
         //去除空格
      let str=cookirArr[i].trim();
 
       let key="username=";
       if(str.startsWith(key)){
         bool=true;
         username=str.substring(key.length,str.length);
         break;
       }
    }
 
    //判断bool标记值
    if(bool){
     console.log(username);
    }else{
         location.href='登录注册.html'
    }
    $.ajax({
        type: "post",
        url: "/js/teashow",
        data: null,
        dataType: "json",
        // success: function (data) {
        //     // document.getElementsByTagName("tbody")[0].innerHTML = data;
        // }
    })

}

//类型回显
function typeshow(type){
    let typeobj ={
        type:type
    }
    $.ajax({
        type: "post",
        url: "/js/typeshow",
        data:JSON.stringify(typeobj),
        dataType: "json",
        success: function (data) {
            if(data != false){
                console.log("有数据");
            }else{
                console.log("暂无数据")
            }
        }
    })
}

// 每个茶叶点击之后
function teaclick(xiabiao){
    
    // let xiabiaoobj ={
    //     xiabiao:num
    // }
    $.ajax({
        type: "post",
        url: "/js/teaclick",
        data:xiabiao,
        dataType: "json",
        success: function (data) {
            if(data){
    window.location.href = '../../Rang茶商店/03茶叶/茶叶简介.html'
            }
        }
    })
}
